const mongoose = require('mongoose')

const userSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
    unique: true
  },
  password: {
    type: String,
    required: true
  },
  role: {
    type: String,
    required: true,
    default: () => 'reporter' // reporter|auditor|admin
  },
  area: {
    type: String, // area 表中的code
    required: false
  },
  deleted: {
    type: Boolean,
    required: true,
    default: () => false
  },
  createdDate: {
    type: Date,
    required: true,
    index: true,
    default: () => Date.now()
  },
  phone: String
})

const userModel = mongoose.model('User', userSchema, 'User')

module.exports = userModel